# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libproxy
pkgver=0.4.17
pkgrel=2
pkgdesc="Library handling all the details of proxy configuration"
url="https://github.com/libproxy/libproxy"
arch="all"
license="LGPL-2.0-or-later"
depends_dev="zlib-dev"
makedepends="cmake python3-dev $depends_dev"
subpackages="$pkgname-dev $pkgname-bin py3-$pkgname:_py:noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/libproxy/libproxy/archive/$pkgver.tar.gz
	"

# secfixes:
#   0.4.15-r9:
#     - CVE-2020-26154
#   0.4.15-r8:
#     - CVE-2020-25219

build() {
	cmake -B build . \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DLIBEXEC_INSTALL_DIR=lib \
		-DMODULE_INSTALL_DIR=/usr/lib/libproxy/$pkgver/modules \
		-DWITH_PERL=OFF \
		-DWITH_PYTHON3=ON \
		-DPYTHON3_EXECUTABLE=/usr/bin/python3
	make -C build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	make -C build DESTDIR="$pkgdir" install

	mkdir -p "$pkgdir"/usr/lib
	mv "$pkgdir"/usr/share/cmake "$pkgdir"/usr/lib
}

bin() {
	pkgdesc="Binary to test libproxy"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

_py() {
	pkgdesc="Binding for libproxy and python 3"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

sha512sums="589045538a78dc7453335ed61c60adad3352b840b224885d4a58ae284e52224ae3ff2eebd77df57aebbc3ae75d7b6d69a825f24f01c19e75bf0a3345dce53126  libproxy-0.4.17.tar.gz"
